<?php 
/*
 * 获取接口说明
 */
function _get_doc($module,$fc,$app){
	$act   = new $module();
	$func  = new ReflectionMethod($act,$fc);
	$tmp   = $func->getDocComment();

	return _change_doc_data($tmp,$module,$fc,$app);
}

/*
 * 解析接口说明
 */
function _change_doc_data($tmp,$module,$fc,$app){
	$p1 = explode('/',$tmp);
	$p2 = explode('*', $p1[1]);
	$p3 = array_filter($p2);
	$param = '<table class="table table-bordered table-striped">
				<thead>
		        <tr>
		          <th>类型</th>
		          <th>参数名称</th>
				  <th>是否必须</th>
				  <th>说明</th>
		        </tr>
		      	</thead><tbody>';
	$return = '<table class="table table-bordered table-striped">
				<thead>
		        <tr>
		          <th>类型</th>
		          <th>返回字段</th>
				  <th>说明</th>
		        </tr>
		      	</thead><tbody>';
	$desc = '';
	$apiurl = C('ApiBaseUrl').'/'.C('DocsBaseApp').'/'.$app.'/'.$fc.'?';
	$apiparam = '';
	foreach($p3 as $p){
		//$result[] = array_filter(explode(' ', $p));
		$str = str_replace(PHP_EOL, '', $p);
		$tmparr = array_filter(explode(' ', $str));
		
		$type = $tmparr[1];
		if($type == '@desc'){
			$desc = $tmparr[2];
		}
		
		if($type == '@param'){
			$tmp = '<tr>';
			for($i = 2; $i < 6;$i++){
				$tmp .= '<td>'.$tmparr[$i].'</td>';
			}
			$tmp .= '</tr>';
			$apiparam .= $tmparr[3].'=&'; 
			$param .= $tmp;
		}
		
		if($type == '@return'){
			$tmp = '<tr>';
			for($i = 2; $i < 5;$i++){
				$tmp .= '<td>'.$tmparr[$i].'</td>';
			}
			$tmp .= '</tr>';
				
			$return .= $tmp;
		}
	}
	
	$param .= '</tbody></table>';
	$return .= '</tbody></table>';
	
	$result['desc'] = $desc;
	$result['param'] = $param;
	$result['return'] = $return;
	$tokens = _create_token();
	$result['apiurl'] = $apiurl.$apiparam.'token='.$tokens[0];
	return $result;
}